/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;
import Model.ComputerPlayer;
import Model.HumanPlayer;
import Model.Player;
import Model.Token;
import View.ImageViewer;
import java.util.*;
import javax.swing.*;

/**
 *
 * @author Tom Gurung
 */
public class Driver {
    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        
        System.out.println("\n****************************************************************************************************");
        System.out.println("Welcome to Group I's Uppers and Downers game");
        System.out.println("Would you like to start?(start to start or anything to quit)");
        String temp = in.nextLine();
        if(temp.equalsIgnoreCase("start")) {
            System.out.print("To begin please enter your name and the board will be displayed: ");
            String name = in.nextLine();

                ImageViewer viewPic = new ImageViewer();
                viewPic.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                viewPic.setVisible(true);
                viewPic.pack();
                viewPic.setTitle("Group I");

            Game playGame = new Game(name, "Comp");

            playGame.startGame();

            System.out.println("Right lets decide who goes first: ");

            boolean starter = playGame.decideGo();

            Player humPlayer = new HumanPlayer(name);
            Player compPlayer = new ComputerPlayer();

            Token humToken = new Token(humPlayer, 1);
            Token compToken = new Token(compPlayer, 1);

            String roll = "r";
            int humanScore; int compScore;
            while (roll.equalsIgnoreCase("r")) {
                if(starter) {
                    humanScore = playGame.humanGo(humPlayer, humToken, compToken);
                    compScore = playGame.compGo(compPlayer, compToken, humToken);
                }
                else {
                    compScore = playGame.compGo(compPlayer, compToken, humToken);
                    humanScore = playGame.humanGo(humPlayer, humToken, compToken);
                }
                    roll = "r";
            }
        } else {
            System.out.println("Thankyou for visiting!");
            System.exit(0);
        }
        
    }
    
}
